var cuaSoXemGiaoDich;
function OpenHelp(url){
    var abc=window.open('','cuaSoXemGiaoDich','width=700,height=550,location=yes,directories=yes,menubar=yes,resizable=yes,scrollbars=yes');
    abc.focus();
    abc.location.href=url;
    return false;
}
function goToPageElement(idname)
{
	if (document.getElementById)
	{
		return document.getElementById(idname);
	}
	else if (document.all)
	{
		return document.all[idname];
	}
	else if (document.layers)
	{
		return document.layers[idname];
	}
	else
	{
		return null;
	}
}

function maximumSize(){
	window.resizeTo(screen.width,screen.height);
	window.moveTo(0,0);
}
function selectText(txt){
	txt.select();
}
function formatDateInput(txt){
	if(txt.value.length>10){
		txt.value=txt.value.substring(0,10);
		return;
	}
	if(txt.value.length==2 && (txt.value.indexOf("/")==-1)){
		txt.value+="/";
	}
	if(txt.value.length==5 && (txt.value.substr(txt.value.length-1)!="/"))
		txt.value+="/";
}
function formatTien(txtId)
{
	var nStr = '';
	nStr+=txtId.value;
	while(nStr.indexOf(',')>=0){
		nStr=nStr.replace(',','');	
	}
	nStr=nStr.replace(' ','');
	if(isNaN(nStr)){
		alert('Ban phai nhap so vao day');
		return;
	}
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)){
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	txtId.value=x1 + x2;
}
function formatStringTien(nStr){
    while (nStr.indexOf(',') >= 0) {
        nStr = nStr.replace(',', '');
    }
    nStr = nStr.replace(' ', '');
    if (isNaN(nStr)) {
        alert('Ban phai nhap so vao day');
        return;
    }
    x = nStr.split('.');
    x1 = x[0];
    x2 = x.length > 1 ? '.' + x[1] : '';
    var rgx = /(\d+)(\d{3})/;
    while (rgx.test(x1)) {
        x1 = x1.replace(rgx, '$1' + ',' + '$2');
    }
    return x1 + x2;
}
function lamTronSo(number, decimals) { // Arguments: number to round, number of decimal places
    var newnumber = new Number(number + '').toFixed(parseInt(decimals));
    return parseFloat(newnumber); // Output the result to the form field (change for your purposes)
}
function showAndHiddenSelect(visibility)
{
	var arraySelect=document.getElementsByTagName('select');
	for(var i=0;i<arraySelect.length;i++)
	{
		arraySelect[i].style.visibility=visibility;
	}
}
function showAndHiddenUL(visibility)
{
	var arrayUL=document.getElementsByTagName('tt');
	for(var i=0;i<arrayUL.length;i++)
	{
		arrayUL[i].style.visibility=visibility;
	}
}
function openPage(url)
{
	showMaskLayer();
	//show mail;
	var PreviewNewsletterDiv=document.getElementById('PreviewNewsletter');
	PreviewNewsletterDiv.style.display='block';
	// Center this div
	makeDivInCenter(document, window, PreviewNewsletter);
	document.getElementById('Iframe1').src=url;
}
function openPageXemGiaoDich(url){
    var abc=window.open('','CuaSoXemGiaoDich','width=700,height=550,location=yes,directories=yes,menubar=yes,resizable=yes,scrollbars=yes');
    abc.focus();
    abc.location.href=url;
    return false;
}
function openPageXemGiaoDichRefresh(tag,url){
    var cu = document.getElementById(tag).parentNode.parentNode;
    var abc=window.open('','CuaSoXemGiaoDich','width=700,height=550,location=yes,directories=yes,menubar=yes,resizable=yes,scrollbars=yes');
    abc.location.href=url;
    window.location = window.location;
    abc.focus();
    return false;
}
function closeMe() {
    result = window.confirm("do you really want to close me?");
    {
        if (result == true) { window.alert(result); }
        else { window.alert(result); }
    }
}